import request from "@/utils/request.js";
import { setting } from "@/config/setting";

const { tokenName } = setting;
const baseUrl = "/game/user";
export const login = async (data) => {
  return request({
    // url: '/login',
    url: `${baseUrl}/login`,
    method: "post",
    data
  });
};

export const getIdByUsername = async (username) => {
  return request({
    // url: '/login',
    url: `${baseUrl}/getUsername/${username}`,
    method: "get",
  });
};

export const getUserInfo = (accessToken) => {
  return request({
    url: `${baseUrl}/userInfo`,
    method: "get",
    data: {
      [tokenName]: accessToken
    }
  });
};

export const logout = () => {
  return request({
    url: `${baseUrl}/logout`,
    method: "post"
  });
};

export const register = async () => {
  return request({
    url: `${baseUrl}/register`,
    method: "post"
  });
};
